package com.jingze.plugins.monitor.customize;




import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.JSONSerializer;

//新能源电池工作示意装置
//动力电池展示系统
//放电（电）-开            Discharge_Electricity_On
//放电（冷却液）-开     Discharge_Coolant_On
//放电（电）-关            Discharge_Electricity_Off
//放电（冷却液）-关     Discharge_Coolant_Off
//充电（电）-开           Charge_Electricity_On
//充电（冷却液）-开    Charge_Coolant_On
//充电（电）-关           Charge_Electricity_Off
//充电（冷却液）-关    Charge_Coolant_Off
//冷却液温度-高           Coolant_Temperature_High
//冷却液温度-低           Coolant_Temperature_Low
public class Run {

    /**
     *
     * @param path 文件全路径 例如 E://fond/***.json
     * @return
     * @throws InterruptedException
     */
    public int doRun(String path) throws InterruptedException {
        String stringJson =FileUtil.readJsonFile(path);
        return putRun(stringJson);
    }
//
//	public int Discharge_Electricity_On() throws InterruptedException {
//		String stringJson ="Discharge_Electricity_On.json";
//	    return putRun(stringJson);
//    }
//
//	public int Discharge_Coolant_On() throws InterruptedException {
//		String stringJson ="Discharge_Coolant_On.json";
//		return putRun(stringJson);
//    }
//
//	public int Discharge_Electricity_Off() throws InterruptedException {
//		String stringJson ="Discharge_Electricity_Off.json";
//	    return putRun(stringJson);
//    }
//
//	public int Discharge_Coolant_Off() throws InterruptedException {
//		String stringJson ="Discharge_Coolant_Off.json";
//		return putRun(stringJson);
//    }
//	public int Charge_Electricity_On() throws InterruptedException {
//		String stringJson ="Charge_Electricity_On.json";
//	    return putRun(stringJson);
//    }
//
//	public int Charge_Coolant_On() throws InterruptedException {
//		String stringJson ="Charge_Coolant_On.json";
//		return putRun(stringJson);
//    }
//
//	public int Charge_Electricity_Off() throws InterruptedException {
//		String stringJson ="Charge_Electricity_Off.json";
//	    return putRun(stringJson);
//    }
//
//	public int Charge_Coolant_Off() throws InterruptedException {
//		String stringJson ="Charge_Coolant_Off.json";
//		return putRun(stringJson);
//    }
//
//	public int Coolant_Temperature_High() throws InterruptedException {
//		String stringJson ="Coolant_Temperature_High.json";
//		return putRun(stringJson);
//    }
//
//	public int Coolant_Temperature_Low() throws InterruptedException {
//		String stringJson ="Coolant_Temperature_Low.json";
//		return putRun(stringJson);
//    }


    public int putRun(String stringJson) throws InterruptedException {
        //转为lightList
        JSONArray lightList = JSONObject.parseArray(stringJson);
        //获取light的执行路径
        String LightsJson = lightList.get(0).toString();
        //获取artNet的信息
        String artNetInfoJson = lightList.get(1).toString();
        ArtNetInfo artNetInfo = JSONArray.parseObject(artNetInfoJson, ArtNetInfo.class);
        //artNet服务器地址
        String artNetAdress=artNetInfo.getArtNetAdress();
        //同时亮灯数量
        int togetherNumLights=artNetInfo.getTogetherNumLights();
        //循环次数
        int repeatNum=artNetInfo.getRepeatNum();
        //跑灯速度(单位：秒)
        double runningSpeed=artNetInfo.getRunningSpeed();
        //推向后端开始运行
        doRun dorun = new doRun();
        return dorun.runLights(artNetAdress,togetherNumLights,repeatNum,runningSpeed,LightsJson);
    }

}
